

    //$.showPreloader();
    $("#orderFormDiv").hide();
    var loadedImageCount = 0;


    var order_form = JSON.parse(localStorage.getItem("order_form"));
    for (var i=0;i<order_form.length;i++){
        product = order_form[i];
        var productDiv = document.createElement("div");
        productDiv.className = "product clearfix";
        var productImage = document.createElement("img");
        productImage.src = "http:"+product.pic;
        productImage.style.height = "100px";
        productImage.className = "fl";
        productImage.onload = function(){
            loadedImageCount++;
            if(loadedImageCount == order_form.length){
                $.hidePreloader();
                $("#orderFormDiv").show(300);

            }
        };


        var productInfoDiv = document.createElement("div");

        var titleDiv = document.createElement("div");
        titleDiv.className = "titleDiv fl";
        titleDiv.innerHTML = product.title;

        var priceAndCountDiv = document.createElement("div");
        priceAndCountDiv.className = "priceAndCountDiv";

        var priceSpan = document.createElement("span");
        priceSpan.innerHTML = "&yen; " + (product.price*product.count).toFixed(2);
        priceSpan.pr = product.price;
        priceSpan.className="priceSpan";

        priceAndCountDiv.appendChild(priceSpan);
        productInfoDiv.appendChild(titleDiv);
        productInfoDiv.appendChild(priceAndCountDiv);


        productDiv.appendChild(productImage);
        productDiv.appendChild(productInfoDiv);
        orderFormDiv.appendChild(productDiv);

        var addDiv = document.createElement("span");
        addDiv.className = 'add_Div fr';
        addDiv.innerHTML = "+";
        priceAndCountDiv.appendChild(addDiv);

        var numDiv = document.createElement("span");
        numDiv.className = 'num_Div fr';
        numDiv.innerHTML = product.count;
        numDiv.pc=product.count;
        priceAndCountDiv.appendChild(numDiv);



        var minusDiv = document.createElement("span");
        minusDiv.className = 'minus_Div fr';
        minusDiv.innerHTML = "-";
        priceAndCountDiv.appendChild(minusDiv);





        var minus = document.getElementsByClassName("minus_Div");
        var nums = document.getElementsByClassName("num_Div");
        var adds = document.getElementsByClassName("add_Div");
//var countSpans = document.getElementsByClassName("countSpan");
        var priceSpans = document.getElementsByClassName("priceSpan");

        for(var i=0; i < minus.length; i++){
            minus[i].index = i;
            minus[i].onclick = function () {

                var p = this.index;
                if(parseFloat(nums[p].innerHTML) == 1){
                    this.style.color = "#ccc";
                    $.toast("受不了啦！不能再减啦！");

                    return;
                }
                nums[p].innerHTML = parseInt(nums[p].innerHTML) - 1;
                priceSpans[p].innerHTML = (nums[p].innerHTML*parseFloat(priceSpans[p].pr)).toFixed(2);
                totalPrice();
            };
        }

        for (var j=0; j < adds.length; j++) {
            adds[j].index = j;
            adds[j].onclick = function () {
                var p = this.index;
                nums[p].innerHTML = parseInt(nums[p].innerHTML) + 1;
                priceSpans[p].innerHTML = (nums[p].innerHTML*parseFloat(priceSpans[p].pr)).toFixed(2);
                totalPrice();
            };
        }
        totalPrice();

    }




function totalPrice() {

    var pris = document.getElementsByClassName("priceSpan");
    var nums = document.getElementsByClassName("num_Div");
    var totalCount = 0;
    for(var i = 0;i<pris.length;i++){

            var o = parseFloat(pris[i].pr)*parseInt(nums[i].innerHTML);
            totalCount += o;

    }
    total_prices.innerHTML=totalCount.toFixed(2);
}

    function generateOrder(){

        location = 'http://test.hfjava.com/shop/zfbpay?' +
            'price=0.01&' +
            'subject='+"Under Armour"+'&' +
            'body=Under Armour&myorderno='+
            (new Date()).getTime()+"07";
    }


